package com.ehotting.edsta.system.api.factory;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.domain.system.api.AppVersion;
import com.ehotting.edsta.system.api.RemoteVersionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteVersionFallbackFactory implements FallbackFactory<RemoteVersionService> {
    @Override
    public RemoteVersionService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteVersionService(){

            @Override
            public R<AppVersion> getLatestInfo(String platform, String source) {
                return R.fail("获取失败:" + throwable.getMessage());
            }
        };
    }
}
